package com.cass.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cass.entity.BreakTheRule;
import com.cass.mapper.BreakTheRuleMapper;
import com.cass.service.IBreakTheRuleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 违纪情况表 服务实现类
 * @author wangyou
 */
@Service
public class BreakTheRuleServiceImpl extends ServiceImpl<BreakTheRuleMapper, BreakTheRule> implements IBreakTheRuleService {
@Override
    public List<String> getViolationsByStudentNumber(String studentNumber) {
        QueryWrapper<BreakTheRule> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("student_number", studentNumber);
        List<BreakTheRule> breakTheRules = list(queryWrapper);

        return breakTheRules.stream().map(BreakTheRule::getViolationOfDiscipline)
                .collect(Collectors.toList());
    }
}
